package com.lss.fmap.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.lss.fmap.fragment.AccountFragment;
import com.lss.fmap.fragment.NoteFragment;
import com.lss.fmap.fragment.TaskFragment;

/**
 * 通过viewpager2实现页面滑动效果
 */
public class MainViewPagerAdapter extends FragmentStateAdapter {

    public MainViewPagerAdapter(@NonNull FragmentActivity fragmentActivity) {
        super(fragmentActivity);
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        switch (position) {
            case 0:
                return AccountFragment.newInstance("", "");
            case 1:
                return TaskFragment.newInstance("", "");
            case 2:
                return NoteFragment.newInstance("", "");
            default:
                return AccountFragment.newInstance("", "");
        }
    }

    @Override
    public int getItemCount() {
        return 3; // 三个页面
    }
}